package com.kgame5.xtank3d.model.tank.fsms.barbrot {
import kgame5.k3d.core.math.Vector3D;

import com.kgame5.xtank3d.GameEnum;
import com.kgame5.xtank3d.model.tank.fsms.TankState;
import com.kgame5.xtank3d.vo.MyTankVO;

/**
 * @author kk
 */
public class MeStateBarbActive extends TankState{
	
	//__________________Propetty__________________
	
	//______________________Method___________________
	public function MeStateBarbActive(pvo:MyTankVO){
		super(GameEnum.STATE_TANK_BARB_ACTIVE, pvo);
		
		
	}
	
	//进入状态
	override public function enter(info:Object=null):void{
		
	}

	//执行状态
	override public function update():void{
		_updateBarb();//炮塔跟随鼠标转动
	}
	
	//退出状态
	override public function exit():void{
		
	}
	//炮塔旋转.先计算出整体的，然后减去坦克当前角度，就是炮塔角度
	private var _v3d_barbRot:Vector3D=new Vector3D();
	private function _updateBarb():void{
		
		_v3d_barbRot.copy(p);
		_v3d_barbRot.x= tankVO.input.mouse3DX - _v3d_barbRot.x;
		_v3d_barbRot.z= tankVO.input.mouse3DZ - _v3d_barbRot.z;
		
		var angleA:int=_v3d_barbRot.angleOfXOZ();
		var angleTankBody:int= r.y;
		
		tankVO.barbRotY=angleA-angleTankBody;
	}
}//end of class
}

